/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Jocabulary_GUI.java
 *
 * Created on 15.12.2010, 19:16:07
 */

package jocabulary;

import java.awt.Color;
import java.awt.event.KeyEvent;

/**
 *
 * @author pit
 */
public class Jocabulary_GUI extends javax.swing.JFrame {

    /** Creates new form Jocabulary_GUI */
    public Jocabulary_GUI() {
        initComponents();

        ctrl = new Jocabulary_Controller(this);
        lblListDone.setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        bgOrder = new javax.swing.ButtonGroup();
        bgFilter = new javax.swing.ButtonGroup();
        pVocab = new javax.swing.JPanel();
        lblChooseLanguage = new javax.swing.JLabel();
        cbLanguages = new javax.swing.JComboBox();
        lblChooseItem = new javax.swing.JLabel();
        cbItems = new javax.swing.JComboBox();
        pSetttings = new javax.swing.JPanel();
        lblOrder = new javax.swing.JLabel();
        rbNativeToTranslation = new javax.swing.JRadioButton();
        rbTranslationToNative = new javax.swing.JRadioButton();
        rbRandom = new javax.swing.JRadioButton();
        lblBox = new javax.swing.JLabel();
        rbAll = new javax.swing.JRadioButton();
        rbLT3 = new javax.swing.JRadioButton();
        rbLT2 = new javax.swing.JRadioButton();
        rbLT1 = new javax.swing.JRadioButton();
        chkRequired = new javax.swing.JCheckBox();
        chkRandomAskOrder = new javax.swing.JCheckBox();
        pAsk = new javax.swing.JPanel();
        tfVocableToTranslate = new javax.swing.JTextField();
        tfTranslation = new javax.swing.JTextField();
        lblEnterInfo = new javax.swing.JLabel();
        lblListDone = new javax.swing.JLabel();
        pbVocab = new javax.swing.JProgressBar();
        pStats = new javax.swing.JPanel();
        lblCorrectAnswered = new javax.swing.JLabel();
        tfTimesCorrect = new javax.swing.JTextField();
        lblTotalCorrect = new javax.swing.JLabel();
        tfTotalCorrect = new javax.swing.JTextField();
        lblTotalWrong = new javax.swing.JLabel();
        tfTotalWrong = new javax.swing.JTextField();
        tbtnStart = new javax.swing.JToggleButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Jocabulary");
        setResizable(false);

        lblChooseLanguage.setText("Sprache auswählen:");

        cbLanguages.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbLanguagesItemStateChanged(evt);
            }
        });

        lblChooseItem.setText("Vokabeldatei auswählen:");
        lblChooseItem.setEnabled(false);

        cbItems.setEnabled(false);
        cbItems.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbItemsItemStateChanged(evt);
            }
        });

        org.jdesktop.layout.GroupLayout pVocabLayout = new org.jdesktop.layout.GroupLayout(pVocab);
        pVocab.setLayout(pVocabLayout);
        pVocabLayout.setHorizontalGroup(
            pVocabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pVocabLayout.createSequentialGroup()
                .addContainerGap()
                .add(pVocabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(cbLanguages, 0, 230, Short.MAX_VALUE)
                    .add(lblChooseLanguage, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
                    .add(lblChooseItem, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
                    .add(cbItems, 0, 230, Short.MAX_VALUE))
                .addContainerGap())
        );
        pVocabLayout.setVerticalGroup(
            pVocabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pVocabLayout.createSequentialGroup()
                .addContainerGap()
                .add(lblChooseLanguage)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cbLanguages, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(lblChooseItem)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cbItems, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(88, Short.MAX_VALUE))
        );

        lblOrder.setText("Abfragerichtung:");
        lblOrder.setEnabled(false);

        bgOrder.add(rbNativeToTranslation);
        rbNativeToTranslation.setText("Deutsch - andere Sprache");
        rbNativeToTranslation.setEnabled(false);

        bgOrder.add(rbTranslationToNative);
        rbTranslationToNative.setText("andere Sprache - Deutsch");
        rbTranslationToNative.setEnabled(false);

        bgOrder.add(rbRandom);
        rbRandom.setSelected(true);
        rbRandom.setText("Zufällig");
        rbRandom.setEnabled(false);

        lblBox.setText("Anzahl richtig beantwortet:");
        lblBox.setEnabled(false);

        bgFilter.add(rbAll);
        rbAll.setSelected(true);
        rbAll.setText("Alle");
        rbAll.setEnabled(false);

        bgFilter.add(rbLT3);
        rbLT3.setText("<3");
        rbLT3.setEnabled(false);

        bgFilter.add(rbLT2);
        rbLT2.setText("<2");
        rbLT2.setEnabled(false);

        bgFilter.add(rbLT1);
        rbLT1.setText("<1");
        rbLT1.setEnabled(false);

        chkRequired.setText("Nur als Wichtig markierte fragen");
        chkRequired.setEnabled(false);

        chkRandomAskOrder.setSelected(true);
        chkRandomAskOrder.setText("Zufällige Abfragereihenfolge");
        chkRandomAskOrder.setEnabled(false);

        org.jdesktop.layout.GroupLayout pSetttingsLayout = new org.jdesktop.layout.GroupLayout(pSetttings);
        pSetttings.setLayout(pSetttingsLayout);
        pSetttingsLayout.setHorizontalGroup(
            pSetttingsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pSetttingsLayout.createSequentialGroup()
                .addContainerGap()
                .add(pSetttingsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pSetttingsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, chkRequired, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, pSetttingsLayout.createSequentialGroup()
                            .add(rbAll)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(rbLT3)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(rbLT2)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(rbLT1))
                        .add(org.jdesktop.layout.GroupLayout.LEADING, lblBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, lblOrder, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 271, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, rbNativeToTranslation, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, rbTranslationToNative, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, rbRandom, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(chkRandomAskOrder))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pSetttingsLayout.setVerticalGroup(
            pSetttingsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pSetttingsLayout.createSequentialGroup()
                .addContainerGap()
                .add(lblOrder)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(rbNativeToTranslation)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(rbTranslationToNative)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(rbRandom)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(lblBox)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pSetttingsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(rbAll)
                    .add(rbLT3)
                    .add(rbLT2)
                    .add(rbLT1))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(chkRequired)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(chkRandomAskOrder)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tfVocableToTranslate.setEditable(false);
        tfVocableToTranslate.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        tfVocableToTranslate.setEnabled(false);

        tfTranslation.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        tfTranslation.setEnabled(false);
        tfTranslation.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tfTranslationKeyPressed(evt);
            }
        });

        lblEnterInfo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblEnterInfo.setText("ENTER zum Überprüfen!");
        lblEnterInfo.setEnabled(false);

        lblListDone.setFont(new java.awt.Font("Lucida Grande", 0, 15));
        lblListDone.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblListDone.setText("Alle Vokabeln abgefragt!");

        pbVocab.setString("-/-");
        pbVocab.setStringPainted(true);

        org.jdesktop.layout.GroupLayout pAskLayout = new org.jdesktop.layout.GroupLayout(pAsk);
        pAsk.setLayout(pAskLayout);
        pAskLayout.setHorizontalGroup(
            pAskLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pAskLayout.createSequentialGroup()
                .addContainerGap()
                .add(pAskLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(tfTranslation, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
                    .add(tfVocableToTranslate, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, lblEnterInfo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
                    .add(pbVocab, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, lblListDone, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
                .addContainerGap())
        );
        pAskLayout.setVerticalGroup(
            pAskLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pAskLayout.createSequentialGroup()
                .addContainerGap()
                .add(tfVocableToTranslate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 45, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(tfTranslation, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 45, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(lblEnterInfo)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(pbVocab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(lblListDone)
                .add(30, 30, 30))
        );

        lblCorrectAnswered.setText("Vokabel richtig:");
        lblCorrectAnswered.setEnabled(false);

        tfTimesCorrect.setEditable(false);
        tfTimesCorrect.setText("0 mal");
        tfTimesCorrect.setEnabled(false);

        lblTotalCorrect.setText("Richtig beantwortet:");
        lblTotalCorrect.setEnabled(false);

        tfTotalCorrect.setEditable(false);
        tfTotalCorrect.setText("0 Stück");
        tfTotalCorrect.setEnabled(false);

        lblTotalWrong.setText("Falsch beantwortet:");
        lblTotalWrong.setEnabled(false);

        tfTotalWrong.setEditable(false);
        tfTotalWrong.setText("0 Stück");
        tfTotalWrong.setEnabled(false);

        org.jdesktop.layout.GroupLayout pStatsLayout = new org.jdesktop.layout.GroupLayout(pStats);
        pStats.setLayout(pStatsLayout);
        pStatsLayout.setHorizontalGroup(
            pStatsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pStatsLayout.createSequentialGroup()
                .addContainerGap()
                .add(pStatsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, tfTotalWrong)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, tfTimesCorrect)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, lblTotalCorrect, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, lblCorrectAnswered, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, lblTotalWrong, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, tfTotalCorrect))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pStatsLayout.setVerticalGroup(
            pStatsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pStatsLayout.createSequentialGroup()
                .addContainerGap()
                .add(lblCorrectAnswered)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(tfTimesCorrect, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(lblTotalCorrect)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(tfTotalCorrect, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(lblTotalWrong)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(tfTotalWrong, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        tbtnStart.setText("Start!");
        tbtnStart.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                tbtnStartStateChanged(evt);
            }
        });
        tbtnStart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tbtnStartActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(pVocab, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(pSetttings, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(tbtnStart)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(pAsk, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(pStats, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, pAsk, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)
                    .add(pStats, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, tbtnStart, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, pVocab, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, pSetttings, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cbLanguagesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbLanguagesItemStateChanged
        try {
            ctrl.selectLanguage(cbLanguages.getSelectedIndex());
        } catch(Exception e) {}
    }//GEN-LAST:event_cbLanguagesItemStateChanged

    private void cbItemsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbItemsItemStateChanged
        try {
            ctrl.selectItem(cbItems.getSelectedIndex());
        } catch(Exception e) {}
    }//GEN-LAST:event_cbItemsItemStateChanged

    private void tfTranslationKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfTranslationKeyPressed
        if(evt.getKeyCode() == KeyEvent.VK_ENTER) {
            ctrl.actionPerformed(tfTranslation.getText());
        }
    }//GEN-LAST:event_tfTranslationKeyPressed

    private void tbtnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbtnStartActionPerformed
        if(tbtnStart.isSelected()) {
            int settingOrder;
            int settingTimesCorrect = 3;

            if(rbNativeToTranslation.isSelected()) {
                settingOrder = 1;
            } else if(rbTranslationToNative.isSelected()) {
                settingOrder = 2;
            } else {
                settingOrder = 0;
            }

            if(rbAll.isSelected()) {
                settingTimesCorrect = 3;
            } if(rbLT3.isSelected()) {
                settingTimesCorrect = 2;
            } if(rbLT2.isSelected()) {
                settingTimesCorrect = 1;
            } if(rbLT1.isSelected()) {
                settingTimesCorrect = 0;
            }

            ctrl.start(settingOrder, settingTimesCorrect, chkRequired.isSelected(), chkRandomAskOrder.isSelected());
        } else {
            tfVocableToTranslate.setText("");
            tfTranslation.setText("");
            tfTranslation.setBackground(Color.white);
            ctrl.stop();
        }
    }//GEN-LAST:event_tbtnStartActionPerformed

    private void tbtnStartStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tbtnStartStateChanged
        if(tbtnStart.isSelected())
            tbtnStart.setText("Stop!");
        else
            tbtnStart.setText("Start!");
    }//GEN-LAST:event_tbtnStartStateChanged

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Jocabulary_GUI().setVisible(true);
            }
        });
    }

    public void addLanguage(String pCleanName) {
        cbLanguages.addItem(pCleanName);
    }
    public void addItem(String pCleanName) {
        cbItems.addItem(pCleanName);
    }
    public void clearLanguages() {
        cbLanguages.removeAllItems();
    }
    public void clearItems() {
        cbItems.removeAllItems();
    }

    public void rbNativeToTranslation_setText(String text) {
        rbNativeToTranslation.setText(text);
    }
    public void rbTranslationToNative_setText(String text) {
        rbTranslationToNative.setText(text);
    }

    public void enableLanguages(boolean state) {
        lblChooseLanguage.setEnabled(state);
        cbLanguages.setEnabled(state);
    }
    public void enableItems(boolean state) {
        lblChooseItem.setEnabled(state);
        cbItems.setEnabled(state);
    }
    public void enableSettings(boolean state) {
        chkRequired.setEnabled(state);
        chkRandomAskOrder.setEnabled(state);
        lblBox.setEnabled(state);
        lblOrder.setEnabled(state);
        rbAll.setEnabled(state);
        rbLT1.setEnabled(state);
        rbLT2.setEnabled(state);
        rbLT3.setEnabled(state);
        rbNativeToTranslation.setEnabled(state);
        rbTranslationToNative.setEnabled(state);
        rbRandom.setEnabled(state);

    }
    public void enableAskAndStats(boolean state) {
        enableLanguages(!state);
        enableItems(!state);
        enableSettings(!state);
        lblCorrectAnswered.setEnabled(state);
        lblEnterInfo.setEnabled(state);
        lblTotalCorrect.setEnabled(state);
        lblTotalWrong.setEnabled(state);
        tfTimesCorrect.setEnabled(state);
        tfTranslation.setEnabled(state);
        tfVocableToTranslate.setEnabled(state);
        tfTotalCorrect.setEnabled(state);
        tfTotalWrong.setEnabled(state);
    }

    public void answerCorrect() {
        tfTranslation.setBackground(Color.green);
    }
    public void answerWrong(String pCorrectTranslation) {
        tfTranslation.setBackground(Color.red);
        tfTranslation.setText(pCorrectTranslation);
    }
    public void askVocable(String pVocableToTranslate) {
        tfVocableToTranslate.setText(pVocableToTranslate);
        tfTranslation.setBackground(Color.white);
        tfTranslation.setText("");
    }
    public void setStats(int pTimesCorrect, int pTotalCorrect, int pTotalWrong) {
        tfTimesCorrect.setText(pTimesCorrect+" mal");
        tfTotalCorrect.setText(pTotalCorrect+" Stück");
        tfTotalWrong.setText(pTotalWrong+" Stück");
    }
    public void clearFields() {
        tfVocableToTranslate.setText("");
        tfTranslation.setText("");
        tfTranslation.setBackground(Color.white);
    }
    public void setProgress(int pValue, int pVocabCount) {
        pbVocab.setMaximum(pVocabCount);
        pbVocab.setValue(pValue);
        pbVocab.setString(pValue+"/"+pVocabCount);
    }
    public void listDone(boolean state) {
        lblListDone.setVisible(state);
    }

    public void tbtnStartSetSelected(boolean state) {
        tbtnStart.setSelected(state);
    }

    private Jocabulary_Controller ctrl;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup bgFilter;
    private javax.swing.ButtonGroup bgOrder;
    private javax.swing.JComboBox cbItems;
    private javax.swing.JComboBox cbLanguages;
    private javax.swing.JCheckBox chkRandomAskOrder;
    private javax.swing.JCheckBox chkRequired;
    private javax.swing.JLabel lblBox;
    private javax.swing.JLabel lblChooseItem;
    private javax.swing.JLabel lblChooseLanguage;
    private javax.swing.JLabel lblCorrectAnswered;
    private javax.swing.JLabel lblEnterInfo;
    private javax.swing.JLabel lblListDone;
    private javax.swing.JLabel lblOrder;
    private javax.swing.JLabel lblTotalCorrect;
    private javax.swing.JLabel lblTotalWrong;
    private javax.swing.JPanel pAsk;
    private javax.swing.JPanel pSetttings;
    private javax.swing.JPanel pStats;
    private javax.swing.JPanel pVocab;
    private javax.swing.JProgressBar pbVocab;
    private javax.swing.JRadioButton rbAll;
    private javax.swing.JRadioButton rbLT1;
    private javax.swing.JRadioButton rbLT2;
    private javax.swing.JRadioButton rbLT3;
    private javax.swing.JRadioButton rbNativeToTranslation;
    private javax.swing.JRadioButton rbRandom;
    private javax.swing.JRadioButton rbTranslationToNative;
    private javax.swing.JToggleButton tbtnStart;
    private javax.swing.JTextField tfTimesCorrect;
    private javax.swing.JTextField tfTotalCorrect;
    private javax.swing.JTextField tfTotalWrong;
    private javax.swing.JTextField tfTranslation;
    private javax.swing.JTextField tfVocableToTranslate;
    // End of variables declaration//GEN-END:variables

}
